#ifndef LOG_H
#define LOG_H

#include <QtGui>

#include "logout.h"
#include "formlog.h"


/**
 * @author PERIGNON TAFFOREAU
 * @brief À compléter
 *
 */
/* Define pour faciliter l'appel des fonction de log
 * Attention avec les LOG vous ne pouvez utilisé de QString
 * directement faut le passé en param, si vous voulez plus
 * de param vous pouvez ajouté des defines */
#define LOG(type, msg) Log::out(type, metaObject()->className(), \
    trUtf8(msg))

#define LOG1(type, msg, param) Log::out(type, metaObject()->className(), \
    trUtf8(msg).arg(param))

#define LOG2(type, msg, param, param2) Log::out(type, metaObject()->className(), \
    trUtf8(msg).arg(param).arg(param2))

#define LOG3(type, msg, param, param2, param3) Log::out(type, metaObject()->className(), \
    trUtf8(msg).arg(param).arg(param2).arg(param3))

#define LOG4(type, msg, param, param2, param3, param4) Log::out(type, \
    metaObject()->className(), \
    trUtf8(msg).arg(param).arg(param2).arg(param3).arg(param4))

class Log : public QObject
{
private :


public:
    Log();

    static void out(LogOut type, QString message){

        if(statusBar != NULL && type == OSTATUS){

        }

        if(messageLog != NULL){
            messageLog->out(type, message);
        }

        qDebug() << getTypeName(type) << message;
    }

    static void out(LogOut type, QString module, QString message){

        if(statusBar != NULL && type == OSTATUS){

        }

        if(messageLog != NULL){
            messageLog->out(type, module, message);
        }

        qDebug() << getTypeName(type) << module << message;
    }

    static void setStatusBar(QStatusBar *s){
        statusBar = s;
    }

    static void setMessageLog(FormLog *m){
        messageLog = m;
    }

    static QString getTypeName(LogOut type){
        switch(type){
            case OINFO:
                return "info";
            case ONOTICE:
                return "notice";
            case OERREUR:
                return "erreur";
            case OSTATUS:
                return "status";
            case OWARNING:
                return "warning";
            case ODEBUG:
                return "debug";
            default:
                return "unset";
        }

    }

protected:
    static FormLog *messageLog;
    static QStatusBar *statusBar;
};

#endif // LOG_H
